#include<stdio.h>
int main()
{
    int n,a=1;
    scanf("%d",&n);
    while(a)
    {
        if(n%5==1&&n%6==5&&n%7==6&&n%11==10) 
        {
            printf("%d",n);
            a=0;
        }
        else n++;
    }
    return 0;
}